<template>
	<view class="pay-content">
		<view class="patient-msg-show">
			<view class="information-title">
				<image class="img" src="@/static/img/pay/line.png" mode=""></image>
				<!-- <img src="@/static/img/pay/line.png" alt=""> -->
				<text>基本信息</text>
			</view>
			<view class="patient-msg-row">
				<text>就诊人</text>
				<text v-if="info.userVisitCard">{{info.userVisitCard.username}}</text>
			</view>
			<view class="patient-msg-row">
				<text>就诊医生</text>
				<text v-if="info.expert">{{info.expert.realName}}</text>
			</view>
			<view class="patient-msg-row">
				<text>性别</text>
				<text v-if="info.userVisitCard">{{info.userVisitCard.sex==0?'女':'男'}}</text>
			</view>
			<!-- 	<view class="patient-msg-row">
				<text>年龄</text>
				<text>{{'咳咳咳'}}</text>
			</view> -->
		</view>
		<view class="illness-description-row">
			<view class="illness-description-title">
				<image class="img" src="@/static/img/pay/line.png" mode=""></image>
				<!-- <img src="@/static/img/pay/line.png" alt=""> -->
				<text>问题描述</text>
			</view>
			<view class="illnessDescription-content">
				<text>{{info.description}}</text>
				<view class="illnessDescription-img" v-if="imgSrc.length>0">
					<image class="img"
					 @tap="preimg(index)"
					 :src="item" v-for="(item,index) in imgSrc" :key="index" mode=""></image>
				</view>
			</view>
		</view>
		<view class="pay-row">
			<view class="price-all">
				<text>合计:</text>
				<text>￥{{info.money}}</text>
				<text>{{info.registerPrice}}</text>
			</view>
			<view class="pay-btn-row">
				<u-button type="default" shape="circle" text="立即支付" class="pay-btn" @click="payHandle"
					hover-class="none"> {{info.money==0?'立即咨询':'立即支付'}}
				</u-button>
			</view>
		</view>
		<!-- 确认支付弹出框 -->
		<view class="pay-modal">
			<u-popup v-model="isShow" mode="bottom">
				<view class="pay-modal-main">
					<view class="close">
						<image class="img" src="@/static/img/pay/close.png" @tap="closeHandle" mode=""></image>
						<!-- <img src="@/static/img/pay/close.png" alt="" @tap="closeHandle"> -->
					</view>
					<view class="pay-methods-title">
						<text>选择支付方式</text>
					</view>
					<view class="sum">
						<text>￥</text>
						<text>{{info.money?info.money:0}}</text>
					</view>
					<view class="wx-pay">
						<image class="img" src="@/static/img/pay/wx.png" mode=""></image>
						<!-- <img src="@/static/img/pay/wx.png" alt=""> -->
						<text>微信支付</text>
						<u-radio-group v-model="value" @change="radioGroupChange" class="choose">
							<u-radio @change="radioChange" :name="list[0].name" :disabled="list[0].disabled"
								active-color="#F4333C">
							</u-radio>
						</u-radio-group>
					</view>
					<view class="zfb-pay">
						<image class="img" src="@/static/img/pay/zfb.png" mode=""></image>
						<!-- <img src="@/static/img/pay/zfb.png" alt=""> -->
						<text>支付宝</text>
						<u-radio-group v-model="value" @change="radioGroupChange" class="choose">
							<u-radio @change="radioChange" :name="list[1].name" :disabled="list[1].disabled"
								active-color="#F4333C">
							</u-radio>
						</u-radio-group>
					</view>
					<view class="confirm-pay-row">
						<u-button type="default" shape="circle" text="确认支付" class="confirm-pay-btn"
							@click="confirmPayHandle" hover-class="none">确认支付</u-button>
					</view>
				</view>
			</u-popup>
		</view>
		<view class="kong"></view>
	</view>
</template>

<script>
	import {
		API
	} from "@/config/myApi.js";
	export default {
		data() {
			return {
				//微信支付宝支付选中
				list: [{
						name: 'wx',
						disabled: false
					},
					{
						name: 'zfb',
						disabled: false
					},
				],
				//支付方式
				value: 'wx',
				//调取支付弹窗
				isShow: false,
				//就诊人信息
				info: {},
				imgSrc: []
			}
		},
		onLoad(e) {
			console.log(e, e.id, 999);
			this.getdata(e.id)
		},
		methods: {
			preimg(index){
				uni.previewImage({
					count:index,
					urls:this.imgSrc
				})
			},
			getdata(id) {
				API.getPayDetail(id).then(res => {
					if (res.code == 200) {
						this.info = res.result
						if (this.info.descriptionImage != '') {
							if (this.info.descriptionImage.indexOf == -1) {
								this.imgSrc = this.info.descriptionImage
							} else {
								this.imgSrc = this.info.descriptionImage.split(',')
							}
						}
					} else {
						uni.showToast({
							title: '获取支付信息失败！',
							icon: 'none',
						})
					}
				})
			},
			// 点击支付
			payHandle() {
				this.isShow = true;
			
			},
			//取消支付
			closeHandle() {
				this.isShow = false;
			},
			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				// this.value = e;
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				// this.value = e;
			},
			//确认支付
			confirmPayHandle() {
				if (this.value == 'wx') {
					console.log('调用微信支付');
				} else {
					console.log('调用支付宝支付');
				}
				uni.navigateTo({
					url:'/pages/tabbar/user/webscoket'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.pay-content {
		padding: 0rpx 30rpx;
		overflow: hidden;

		.patient-msg-show {
			margin-top: 30rpx;

			.information-title {
				display: flex;
				align-items: center;
				margin-bottom: 20rpx;

				.img {
					width: 5rpx;
					height: 28rpx;
				}

				>text {
					font-size: 30rpx;
					font-weight: bold;
					color: #333333;
					margin-left: 10rpx;
				}
			}

			.patient-msg-row {
				display: flex;
				justify-content: space-between;
				align-items: center;
				background: #fff;
				border-radius: 12rpx;
				padding: 40rpx 24rpx 20rpx;

				>text:first-child {
					font-size: 30rpx;
					color: #999999;
				}

				>text:last-child {
					font-size: 30rpx;
					color: #333333;
				}
			}

			.patient-msg-row:last-child {
				padding-bottom: 40rpx;
			}
		}

		.illness-description-row {
			margin-top: 50rpx;

			.illness-description-title {
				display: flex;
				align-items: center;
				margin-bottom: 20rpx;

				.img {
					width: 5rpx;
					height: 28rpx;
				}

				>text {
					font-size: 30rpx;
					font-weight: bold;
					color: #333333;
					margin-left: 10rpx;
				}
			}

			.illnessDescription-content {
				padding: 40rpx 24rpx;
				border-radius: 12rpx;
				background: #fff;

				>text {
					font-size: 28rpx;
					color: #333333;
				}

				.illnessDescription-img {
					display: flex;
					margin-top: 22rpx;

					.img {
						width: 200rpx;
						height: 200rpx;
						margin-right: 21rpx;
						border-radius: 12rpx;
						overflow: hidden;
					}

					.img:last-child {
						margin: 0rpx;
					}
				}
			}
		}

		.pay-row {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100vw;
			height: 132rpx;
			padding: 0rpx 30rpx;
			background: #fff;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.price-all {
				>text:nth-of-type(1) {
					font-size: 24rpx;
					color: #666666;
				}

				>text:nth-of-type(2) {
					font-size: 24rpx;
					color: #F4333C;
				}

				>text:nth-of-type(3) {
					font-size: 34rpx;
					font-weight: bold;
					color: #F4333C;
				}
			}

			.pay-btn-row {
				.pay-btn {
					background-color: #F4333C;
					color: #fff;
					width: 260rpx;
					height: 80rpx;
				}

				.u-hairline-border:after {
					border: none;
				}
			}
		}

		.pay-modal {
			border-radius: 24rpx;
			background: #fff;

			.pay-modal-main {
				padding: 32rpx 30rpx;

				.close {
					display: flex;

					.img {
						margin-left: auto;
						width: 28rpx;
						height: 28rpx;
					}
				}

				.pay-methods-title {
					text-align: center;
					font-size: 34rpx;
					font-weight: bold;
					color: #333333;
				}

				.sum {
					text-align: center;
					margin-top: 60rpx;

					>text:first-child {
						font-size: 30rpx;
						color: #F4333C;
					}

					>text:last-child {
						font-size: 60rpx;
						color: #F4333C;
						font-weight: bold;
					}
				}

				.wx-pay {
					display: flex;
					align-items: center;
					margin-top: 90rpx;

					.img {
						width: 37rpx;
						height: 32rpx;
					}

					>text {
						font-size: 30rpx;
						font-weight: bold;
						color: #333333;
						margin-left: 12rpx;
					}

					.choose {
						margin-left: auto;
					}
				}

				.zfb-pay {
					display: flex;
					align-items: center;
					margin-top: 71rpx;

					.img {
						width: 33rpx;
						height: 32rpx;
					}

					>text {
						font-size: 30rpx;
						font-weight: bold;
						color: #333333;
						margin-left: 12rpx;
					}

					.choose {
						margin-left: auto;
					}
				}

				.confirm-pay-row {
					margin-top: 100rpx;

					.confirm-pay-btn {
						background-color: #F4333C;
						color: #fff;
						height: 90rpx;
					}

					.u-hairline-border:after {
						border: none;
					}
				}
			}
		}

		.kong {
			width: 100vw;
			height: 160rpx;
		}
	}

	/deep/.u-drawer-content {
		border-top-right-radius: 32rpx;
		border-top-left-radius: 32rpx;
	}

	/deep/.u-radio {
		width: 36rpx !important;
	}
</style>
